<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
	<title>then返回值</title>
	<style type="text/css">
	* {
		padding: 0;
		margin: 0;
	}
</style>
</head>
<body>
	<div class="container">
		<h1>then返回值</h1>
	</div>
	<script src="https://cdn.staticfile.org/jquery/3.2.0/jquery.js"></script>
	<script type="text/javascript">

		var promise = new Promise(resolve => {
			setTimeout(() => {
				resolve("后盾人");
			});
		});
		var p = promise.then(value => {
			console.log(p, typeof p, Object.prototype.toString.call(p))
			// return p
		});

		var i  = 0 ;
		function fun(callback) {
			var id = setInterval(() => {callback(id)}, 1000)
		}

		fun(function(timer) {
			console.log(`fun timer = ${timer}`)
			if(i++ >=6) {
				clearInterval(timer)
			}
		})

		function interval(callback, delay = 1000) {
			let id = setInterval(() => callback(id), delay);
		}

		interval(function(timerId ) {
			console.log(`interval timerId = ${timerId}`)
			if(i++ >= 3) {
				clearInterval(timerId)
			}
		})
	</script>
</body>
</html>